package svc

import (
	"github.com/zeromicro/go-zero/core/stores/redis"
	"github.com/zeromicro/go-zero/zrpc"
	"mall/app/auth/cmd/api/internal/config"
	"mall/app/member/cmd/rpc/memberservice"
	"mall/app/thirdparty/cmd/rpc/thirdparty"
)

type ServiceContext struct {
	Config        config.Config
	ThirdPartyRpc thirdparty.ThirdParty
	MemberRpc     memberservice.MemberService
	RedisClient   *redis.Redis
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:        c,
		ThirdPartyRpc: thirdparty.NewThirdParty(zrpc.MustNewClient(c.ThirdPartyRpcConf)),
		MemberRpc:     memberservice.NewMemberService(zrpc.MustNewClient(c.MemberRpcConf)),
		RedisClient:   redis.New("localhost:6379"),
	}
}
